package snake.entities;				//Right!

import java.awt.Color;
import java.awt.Graphics;

import snake.util.Global;

public class Ground {
	
	public int[][] rocks = new int[Global.LENGTH][Global.HEIGHT];
	
	public Ground(){
		for(int i=0;i<Global.LENGTH;i++){
			rocks[0][i]=1;
			rocks[Global.HEIGHT-1][i]=1;
		}
		for(int i=0;i<Global.HEIGHT;i++){
			rocks[i][0]=1;
			rocks[i][Global.LENGTH-1]=1;
		}
	}
	
	public boolean isSnakeEatRock(Snake snake){
		System.out.println("Ground isSnakeEatRock");
		for(int x=0;x<Global.LENGTH;x++){
			for(int y=0;y<Global.HEIGHT;y++){
				if(rocks[x][y]==1 && x==snake.getHead().x && y==snake.getHead().y){
					return true;
				}
			}
		}
		return false;
	}
	
	public void draw(Graphics g){
		System.out.println("Ground draw");
		g.setColor(Color.BLUE);
		for(int x=0;x<Global.LENGTH;x++){
			for(int y=0;y<Global.HEIGHT;y++){
				if(rocks[x][y]==1)
					g.fill3DRect(x*Global.CELL_SIZE, y*Global.CELL_SIZE, Global.CELL_SIZE, Global.CELL_SIZE, true);
			}
		}
	}

}
